const licenseWidth = 190
const getLicensesString = function(a) {
  let first = '执业类型未知'
  let all = []
  if (a && Array.isArray(a) && a.length > 0) {
    if (a.length === 1) {
      first = a[0].licenseTypeStr
      all = []
    } else {
      first = a[0].licenseTypeStr + '...'
      all = a.map(t => {
        return t.licenseTypeStr
      })
    }
  }
  return {
    first: first,
    all: all
  }
}


const salaryWidth = 150
const getSalaryItem = function(t) {
  return (t.tax === 0 ? '税前' : '税后') + (t.annualSalary ? t.annualSalary : '0') + 'W/' + (t.yearNum ? t.yearNum : '0') + '年'
}
const getSalaryString = function(a) {
  let first = '期望年薪未知'
  let all = []
  if (a && a.length > 0) {
    if (a.length === 1) {
      first = getSalaryItem(a[0])
      all = []
    } else {
      all = a.map(t => {
        return getSalaryItem(t)
      })
      first = all[0] + '...'
    }
  }
  return {
    first: first,
    all: all
  }
}

function getChatSalaryItem(t) {
  return {
    company: t.hopeCompanyTypeStr,
    license: t.hopeLicenseStr,
    tax: t.taxType,
    salaryLow: t.salaryPerMonthLow,
    salaryHigh: t.salaryPerMonthHigh,
    salaryCount: t.yearNum
  }
}

const chatSalaryWidth = 500
const getChatSalary = function(a) {
  let all = [{
    company: '公司性质未知',
    license: '执业类型未知',
    tax: 0,
    salaryLow: 0,
    salaryHigh: 0,
    salaryCount: 0
  }]
  if (a && a.length > 0) {
    all = a.map(t => {
      return getChatSalaryItem(t)
    })
  }
  console.log('chat salary', all)
  return all
}


export default {
  licenseWidth,
  getLicensesString,
  salaryWidth,
  getSalaryString,
  getChatSalary,
  chatSalaryWidth
}